
#pragma once
#include "DrawCell.h"
#include "TSingle.h"

namespace mini
{
	class CDrawCellManager : public  TSingle<CDrawCellManager>
	{
	public:
		CDrawCellManager();
		~CDrawCellManager();
		
		template<typename T>
		T* getDrawCell()
		{
			int type = T::getType();
			T* pDrawCell = nullptr;
			if (mContains[type].size() > 0)
			{
				pDrawCell = dynamic_cast<T*>(mContains[type].back());
				mContains[type].pop_back();
			}
			else
			{
				pDrawCell = new T();
			}
			return pDrawCell;
		}

		void releaseDrawCell(DrawCell* pCell);

	private:
		std::map<int, std::list<DrawCell*>> mContains;

	};
}





